{% include 'QLGL/QLGL_index.html' %}

<div class="am-cf admin-main">
  {% include 'sidebar.html' %}
  <!-- content start -->
  <div class="admin-content">
    <div class="admin-content-body">
      <div class="am-cf am-padding">
        <div class="am-fl am-cf"><strong class="am-text-primary am-text-lg">巡检业务</strong></div>
      </div>
      <div class="am-g" style="position: absolute;height: 100%;right: 0px;left: 260px;width: auto;">

        {% include 'QLGL/XJYW/QLGL_XJYW_SIDEBAR.html' %}
        
        <div class="am-u-sm-10" style="position: absolute;width:auto;right:0;left: 200px;overflow-y: scroll;bottom: 100px;top: 0px;">
          <div class="am-u-sm-12 am-u-md-6">
            <div class="am-btn-toolbar">
              <div class="am-btn-group am-btn-group-xs">
                <button style="margin: 0 5px"  type="button" class="am-btn am-btn-default am-btn-xs am-text-secondary" onclick="regular_add()"><span class="am-icon-plus"></span>新增</button>
              </div>
            </div>
          </div>

          <table id="grid" class="am-table am-table-striped am-table-hover table-main am-table-compact am-text-nowrap" >
            <thead>
              <tr>
                <th class="table-title">序号</th>
                <th class="table-title">桥梁编号</th>
                <th class="table-title">桥梁名称</th>
                <th class="table-title">责任单位</th>
                <th class="table-title">责任人</th>
                <th class="table-title">检查时间</th>
                <th class="table-title">评定分数</th>
                <th class="table-title">评定等级</th>
                <th class="table-title">定检状态</th>
                <th class="table-title">操作</th>
              </tr>
            </thead>
            <tbody></tbody>
          </table>

        </div>
      </div>
    </div>
  </div>
</div>
{% include 'footer.html' %}
<!--[if lt IE 9]>
<script src="http://libs.baidu.com/jquery/1.11.1/jquery.min.js"></script>
<script src="http://cdn.staticfile.org/modernizr/2.8.3/modernizr.js"></script>
<script src="assets/js/amazeui.ie8polyfill.min.js"></script>
<![endif]-->

<!--[if (gte IE 9)|!(IE)]><!-->
<script src="/static/assets/js/jquery.min.js"></script>
<!--<![endif]-->
<script src="/static/assets/js/amazeui.min.js"></script>
<script src="/static/assets/js/amazeui.tree.js"></script>
<script type="text/javascript" src="/static/assets/js/layer.js"></script>
<script src="/static/assets/datatables/amazeui.datatables.min.js"></script>
<script src="/static/assets/dialog/amazeui.dialog.min.js"></script>
<link rel="stylesheet" type="text/css" href="/static/assets/css/amazeui.tree.css" />
<script src="/static/assets/js/app.js"></script>
<style type="text/css">
  .li_a {
    color: #5c5c5c;
  }
</style>
<script type="text/javascript">
  $("#collapse-nav1").addClass("am-in");
  $("#qlgl").removeClass("am-collapsed");
  $("#qlglOxjyw").css("color", "#3399CC");
  $("#qlgl").css("color", "#3399CC");
  $("#xjywOdqjc").removeClass("li_a");
var t = $('#grid').DataTable({
  //配置DataTables默认参数



    bInfo: true,//页脚信息
    responsive: true,
    searching: true,
    lengthChange: false,
    paging: true,
    bStateSave: true, //保存页面状态
    aLengthMenu: [[10], [10]],
    ajax: {

      url: "/QLXJ_XJYW_DQJC_index_data/?type=1"
    },


    
    //每页显示五条数据
    //pageLength: 'all',
    columns: [
    
      {  
        data : null,  
        bSortable : false,  
        targets : 0,  
        //width : "30px",  
        render : function(data, type, row, meta) {  
          // 显示行号  
          var startIndex = meta.settings._iDisplayStart;  
          return startIndex + meta.row + 1;  
        }  
      },
    
      {
        "data": "bridge_code"
      },
      {
        "data": "bridge_name"
      },

      {
        "data": "check_depart_name"
      },
      {
        "data": "user_charge_name"
      },
      {
        "data": "from_date"
      },
      {
        "data": "score"
      },
      {
        "data": "grade"
      }
      ,
      {
        "data": "status"
      }
      ,
      {
        "data": "status"
      }
    ],
    
    
    "columnDefs": [
      // "visible": false,
      //"targets": 0



      {
        type: 'chinese-string',
        targets: '_all'
      } //中文排序
      ,
      {
        "render": function(data, type, row, meta) {
          if(row.status == 0){
            return "无效"
          }else if(row.status == 1){
            return "开始"
          }else if(row.status == 2){
            return "进行中"
          }else if(row.status == 3){
            return "结束"
          }
          
                  
        },
        "targets": 8
      },
      
      
      {
        "render": function(data, type, row, meta) {
          if(row.status == 3){
            return '<div class="am-btn-toolbar"><div class="am-btn-group am-btn-group-xs"><button class="am-btn am-btn-default am-btn-xs am-text-secondary" onclick="regular_rescore(' + row.check_id + ',\'' + row.bridge_name + '\')"><span class="am-icon-pencil-square-o"></span> 重新评分</button><button class="am-btn am-btn-default am-btn-xs am-text-secondary" onclick="regular_resetscore(' + row.check_id + ',\'' + row.bridge_name + '\')"><span class="am-icon-pencil-square-o"></span> 重置评分</button><button class="am-btn am-btn-default am-btn-xs am-text-secondary" onclick="regular_see(' + row.check_id + ',' + row.bridge_id + ')"><span class="am-icon-pencil-square-o"></span> 查看</button><button class="am-btn am-btn-default am-btn-xs am-text-secondary" onclick="regular_details(' + row.check_id + ')"><span class="am-icon-pencil-square-o"></span> 详情</button><button class="am-btn am-btn-default am-btn-xs am-text-secondary" onclick="regular_export(' + row.check_id + ',\'' + row.bridge_name + '\')"><span class="am-icon-pencil-square-o"></span> 导出报告</button><button class="am-btn am-btn-default am-btn-xs am-text-secondary" onclick="regular_origrs(' + row.check_id + ',\'' + row.bridge_name + '\')"><span class="am-icon-pencil-square-o"></span> 原始记录</button><button class="am-btn am-btn-default am-btn-xs am-text-danger am-hide-sm-only" onclick="regular_delect(' + row.check_id + ',\'' + row.bridge_name + '\')"><span class="am-icon-trash-o"></span> 删除</button></div></div>'
          }else{
            return '<div class="am-btn-toolbar"><div class="am-btn-group am-btn-group-xs"><button class="am-btn am-btn-default am-btn-xs am-text-secondary" onclick="regular_modify(' + row.check_id + ')"><span class="am-icon-pencil-square-o"></span> 修改</button><button class="am-btn am-btn-default am-btn-xs am-text-danger am-hide-sm-only" onclick="regular_delect(' + row.check_id + ',\'' + row.bridge_name + '\')"><span class="am-icon-trash-o"></span> 删除</button><button class="am-btn am-btn-default am-btn-xs am-text-secondary" onclick="regular_score(' + row.check_id + ',\'' + row.bridge_name + '\')"><span class="am-icon-pencil-square-o"></span> 评分</button><button class="am-btn am-btn-default am-btn-xs am-text-secondary" onclick="regular_see(' + row.check_id + ',' + row.bridge_id + ')"><span class="am-icon-pencil-square-o"></span> 查看</button><button class="am-btn am-btn-default am-btn-xs am-text-secondary" onclick="regular_origrs(' + row.check_id + ',\'' + row.bridge_name + '\')"><span class="am-icon-pencil-square-o"></span> 原始记录</button></div></div>'
          }
                  
        },
        //指定是第二列
        "targets": 9
      }
    ],
    

  });

  //新增
function regular_add(){
    //window.location.href="/XTGL_BMGL_ADD/"
  popup("新增定期检查","/QLXJ_XJYW_DQJC_add/?type=1")
}
  //修改
function regular_modify(check_id){
    //window.location.href="/XTGL_BMGL_ADD/"
  popup("修改定期检查","/QLXJ_XJYW_DQJC_mod/?check_id="+check_id+"&type=1")
}
//删除
function regular_delect(check_id,bridge_name){
    AMUI.dialog.confirm({
      title: '删除确认',
      content: '您确认删除['+bridge_name+']的评分单元?',
      onConfirm: function() {
        //console.log('onConfirm,save ' + organize_id);
        $.ajax({
      "url":"/QLXJ_XJYW_DQJC_del/?check_id="+check_id+"",
      "datatype":"json",
      "type":"get",
      "async":"false"
      }).success(function(data){
        if (data.status == 1) {
          message_layer(data.message)
          window.location.reload();
        } else {
          AlertMSG(data.message)
        }
      }).error(function(data){
        AlertMSG("删除失败！")
      });
      },
      onCancel: function() {
        console.log('onCancel')
      }
    });
  };
// message_layer(data.message)
function message_layer(message){
    layer.msg(message, {
    time: 2000 //2秒关闭（如果不配置，默认是3秒）
  }); 
}

  function regular_score(check_id,bridge_name){
    AMUI.dialog.confirm({
      title: '评分确认',
      content: '您确认是否进行['+bridge_name+']的评分?',
      onConfirm: function() {
        //console.log('onConfirm,save ' + organize_id);
        $.ajax({
      "url":"/QLXJ_XJYW_DQJC_SCORE/?check_id="+check_id+"",
      "datatype":"json",
      "type":"get",
      "async":"false"
      }).success(function(data){
        if (data.status == 1) {
          message_layer(data.message)
          window.location.reload();
        } else {
          AlertMSG(data.message)
        }
      }).error(function(data){
        AlertMSG("评分失败！")
      });
      },
      onCancel: function() {
        console.log('onCancel')
      }
    });
  };


  function regular_rescore(check_id,bridge_name){
    AMUI.dialog.confirm({
      title: '重新评分确认',
      content: '您确认是否进行['+bridge_name+']的重新评分?',
      onConfirm: function() {
        //console.log('onConfirm,save ' + organize_id);
        $.ajax({
      "url":"/QLXJ_XJYW_DQJC_RESCORE/?check_id="+check_id+"",
      "datatype":"json",
      "type":"get",
      "async":"false"
      }).success(function(data){
        if (data.status == 1) {
          message_layer(data.message)
          window.location.reload();
        } else {
          AlertMSG(data.message)
        }
      }).error(function(data){
        AlertMSG("重新评分失败！")
      });
      },
      onCancel: function() {
        console.log('onCancel')
      }
    });
  };


  function regular_resetscore(check_id,bridge_name){
    AMUI.dialog.confirm({
      title: '重置评分确认',
      content: '您确认是否进行['+bridge_name+']的重置评分?',
      onConfirm: function() {
        //console.log('onConfirm,save ' + organize_id);
        $.ajax({
      "url":"/QLXJ_XJYW_DQJC_RESETSCORE/?check_id="+check_id+"",
      "datatype":"json",
      "type":"get",
      "async":"false"
      }).success(function(data){
        if (data.status == 1) {
          message_layer(data.message)
          window.location.reload();
        } else {
          AlertMSG(data.message)
        }
      }).error(function(data){
        AlertMSG("重置评分失败！")
      });
      },
      onCancel: function() {
        console.log('onCancel')
      }
    });
  };

  function regular_export(check_id,bridge_name){
    AMUI.dialog.confirm({
      title: '报告导出确认',
      content: '您确认是否导出['+bridge_name+']的报告?',
      onConfirm: function() {
        //console.log('onConfirm,save ' + organize_id);
        $.ajax({
      "url":"/QLXJ_XJYW_DQJC_EXPORT/?check_id="+check_id+"",
      "datatype":"json",
      "type":"get",
      "async":"false"
      }).success(function(data){
        if (data.status == 1) {
          message_layer(data.message)
          window.location.reload();
        } else {
          AlertMSG(data.message)
        }
      }).error(function(data){
        AlertMSG("导出失败！")
      });
      },
      onCancel: function() {
        console.log('onCancel')
      }
    });
  };
  function regular_origrs(check_id,bridge_name){
    AMUI.dialog.confirm({
      title: '查看原始记录确认',
      content: '您确认是否查看['+bridge_name+']的原始记录?',
      onConfirm: function() {
        //console.log('onConfirm,save ' + organize_id);
        $.ajax({
      "url":"/QLXJ_XJYW_DQJC_ORIGRS/?check_id="+check_id+"",
      "datatype":"json",
      "type":"get",
      "async":"false"
      }).success(function(data){
        if (data.status == 1) {
          message_layer(data.message)
          window.location.reload();
        } else {
          AlertMSG(data.message)
        }
      }).error(function(data){
        AlertMSG("查看失败！")
      });
      },
      onCancel: function() {
        console.log('onCancel')
      }
    });
  };
//查看
function regular_see(check_id,bridge_id){
  window.location.href="/QLXJ_XJYW_DQJC_SEE/?check_id="+check_id+"&bridge_id="+bridge_id+"&type=1"
    // popup("修改定期检查","/QLXJ_XJYW_DQJC_mod/?check_id="+check_id+"")
}

function regular_details(check_id){
  window.location.href="/QLXJ_XJYW_DQJC_SCOREDETAIL/?check_id="+check_id+""
    // popup("修改定期检查","/QLXJ_XJYW_DQJC_mod/?check_id="+check_id+"")
}



  

  function popup(title,url){
        var index = layer.open({
            type: 2,
            title: title,
            content: url,
            area: ['600px', '360px'],
            
        });

        
        //铺满界面
        //layer.full(index);
  }
  var AlertMSG=function(msg){
    AMUI.dialog.alert({ title: '错误提示', content: msg, onConfirm: function() { console.log('close'); } });
  }


// function findWeather() {
//   var cityUrl = 'http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js';
//   $.getScript(cityUrl, function(script, textStatus, jqXHR) {
//     var citytq = remote_ip_info.city ;// 获取城市
//     var url = "http://php.weather.sina.com.cn/iframe/index/w_cl.php?code=js&city=" + citytq + "&day=0&dfc=3";
//     $.ajax({
//       url : url,
//       dataType : "script",
//       scriptCharset : "gbk",
//       success : function(data) {
//         var _w = window.SWther.w[citytq][0];
//         var _f= _w.f1+"_0.png";
//         if(new Date().getHours() > 17){
//            _f= _w.f2+"_1.png";        
//         }
//         var img = "<img width='16px' height='16px' src='http://i2.sinaimg.cn/dy/main/weather/weatherplugin/wthIco/20_20/" +_f
//         + "' />";
//         var tq = citytq + " " + img + " " + _w.s1 + " " + _w.t1 + "℃～" + _w.t2 + "℃ " + _w.d1 + _w.p1 + "级";
         
//         console.log(tq)
//       }
//     });
//   });
// }
 
// findWeather();





</script>
 
</body>

</html>